//
// Created by fanghr on 18-3-29.
//

#ifndef NEF_BACKEND_ASHMEM_CPP_H
#define NEF_BACKEND_ASHMEM_CPP_H

#include <cstddef>
#include "ashmem.h"

namespace ashmem_cpp {
    class access;

    class ashmem {
    private:
        int fd;
        bool _close;

        friend class access;

    public:
        ashmem(const char *name, size_t size);

        ashmem(int fd);

        ~ashmem();

        int set_prot_region(int prot);

        int pin_region(size_t offset, size_t len);

        int unpin_region(size_t offset, size_t len);

        int get_size_region();
    };

    class access {
    public:
        static int get_fd(ashmem &obj);

        access() = delete;

        access &operator=(access &)= delete;
    };
}
#endif //NEF_BACKEND_ASHMEM_CPP_H
